package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VExamResultsContact;
import com.ruoyi.system.service.IVExamResultsContactService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基础数据汇总Controller
 * 
 * @author ruoyi
 * @date 2024-12-14
 */
@Controller
@RequestMapping("/system/VExamResultsContact")
public class VExamResultsContactController extends BaseController
{
    private String prefix = "system/VExamResultsContact";

    @Autowired
    private IVExamResultsContactService vExamResultsContactService;

    @RequiresPermissions("system:VExamResultsContact:view")
    @GetMapping()
    public String VExamResultsContact()
    {
        return prefix + "/VExamResultsContact";
    }

    /**
     * 查询基础数据汇总列表
     */
    @RequiresPermissions("system:VExamResultsContact:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(VExamResultsContact vExamResultsContact)
    {
        startPage();
        List<VExamResultsContact> list = vExamResultsContactService.selectVExamResultsContactList(vExamResultsContact);
        return getDataTable(list);
    }

    /**
     * 导出基础数据汇总列表
     */
    @RequiresPermissions("system:VExamResultsContact:export")
    @Log(title = "基础数据汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VExamResultsContact vExamResultsContact)
    {
        List<VExamResultsContact> list = vExamResultsContactService.selectVExamResultsContactList(vExamResultsContact);
        ExcelUtil<VExamResultsContact> util = new ExcelUtil<VExamResultsContact>(VExamResultsContact.class);
        return util.exportExcel(list, "基础数据汇总数据");
    }

    /**
     * 新增基础数据汇总
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存基础数据汇总
     */
    @RequiresPermissions("system:VExamResultsContact:add")
    @Log(title = "基础数据汇总", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(VExamResultsContact vExamResultsContact)
    {
        return toAjax(vExamResultsContactService.insertVExamResultsContact(vExamResultsContact));
    }

    /**
     * 修改基础数据汇总
     */
    @RequiresPermissions("system:VExamResultsContact:edit")
    @GetMapping("/edit/{courseId}")
    public String edit(@PathVariable("courseId") Long courseId, ModelMap mmap)
    {
        VExamResultsContact vExamResultsContact = vExamResultsContactService.selectVExamResultsContactByCourseId(courseId);
        mmap.put("vExamResultsContact", vExamResultsContact);
        return prefix + "/edit";
    }

    /**
     * 修改保存基础数据汇总
     */
    @RequiresPermissions("system:VExamResultsContact:edit")
    @Log(title = "基础数据汇总", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(VExamResultsContact vExamResultsContact)
    {
        return toAjax(vExamResultsContactService.updateVExamResultsContact(vExamResultsContact));
    }

    /**
     * 删除基础数据汇总
     */
    @RequiresPermissions("system:VExamResultsContact:remove")
    @Log(title = "基础数据汇总", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(vExamResultsContactService.deleteVExamResultsContactByCourseIds(ids));
    }
}
